﻿@{
    ViewBag.Title = "Entradas";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@using Helena.Areas.Entradas.Models
@using System.Collections
@using Telerik.Web.Mvc.UI
@model IEnumerable<EntradaView>  
@Html.Telerik().ScriptRegistrar().Globalization(true)
   

<div class="block big" style="position: relative">
    <!-- Block Begin -->
    <div class="titlebar">
        <h3>
            Entrada de Productos
        </h3>
    </div>
    <div class="block_cont">
        @(Html.Telerik().Grid(Model)
        .Name("EntradaGrid")
        .Localizable("es-ES")
        .Filterable()
        .ToolBar(commands => commands.Insert())
                .Editable(editing => editing
                .Mode(GridEditMode.PopUp)
                .TemplateName("TemplateEntrada") )
                .DataKeys(keys => keys.Add(o => o.ID))
                    .Columns(columns =>
                    {
                        columns.Bound(c => c.NumeroFactura);
                        columns.Bound(c => c.NumeroGuia);
                        columns.ForeignKey(c => c.ProveedorID, (IEnumerable)ViewData["Proveedores"], "ID", "RazonSocial");
                        columns.ForeignKey(c => c.VendedorID, (IEnumerable)ViewData["Vendedor"], "ID", "NombreLargo");
                        columns.Bound(c => c.Descripcion);
                        columns.Bound(c => c.Fecha);
                        columns.Bound(c => c.Estado).Width(80).ClientTemplate("<input type='checkbox' disabled='disabled' name='Estado' <#= Estado? checked='checked' : '' #> />");
                        
                        columns.Command(commands =>
                        {
                            commands.Edit().ButtonType(GridButtonType.Image);
                            commands.Custom("AddDetalleEntrada")
                                .Text("+")
                                .DataRouteValues(c => c.Add(x => x.ID).RouteKey("EntradaID"))
                                .Action("AddDetalles", "Entrada");
                        }).Title("Acciones").Width(100);
                    })
                    .Pageable()
                    .Sortable()
                    .Scrollable(scrolling => scrolling.Height(250))
                    .PrefixUrlParameters(false)
                    .DataBinding(dataBinding => dataBinding
                    .Ajax()
                    .Select("Select", "Entrada")
                    .Insert("Insert", "Entrada")
                    .Delete("Delete", "Entrada")
                    .Update("Update", "Entrada")
                                )
                )

            </div>
    <!-- Table Wrapper End -->
</div>
